package com.googlecode.yatspec.rendering.html;

import com.googlecode.totallylazy.Sequence;
import com.googlecode.yatspec.parsing.TestSource;
import com.googlecode.yatspec.parsing.Text;
import com.googlecode.yatspec.rendering.Renderer;

import static com.googlecode.totallylazy.Sequences.sequence;

public class ScalaSourceRenderer implements Renderer<TestSource> {

    @Override
    public String render(TestSource javaSource) throws Exception {
        return lines(javaSource.value().trim()).map(Text.wordify()).toString("\n");
    }

    public static Sequence<String> lines(final String sourceCode) {
        return sequence(sourceCode.split(lineSeperator()));
    }

    public static String lineSeperator() {
        return System.getProperty("line.separator");
    }
}
